package huu.phong.youtube;

import javax.swing.ImageIcon;

public enum Format {
	
	VIDEO_MAX (138, true, false, "", "MP4, Original, H.264"),
	VIDEO_1080 (137, true, false, "", "MP4, 1080p, H.264"),
	VIDEO_720 (136, true, false, "", "MP4, 720p, H.264"),
	VIDEO_480 (135, true, false, "", "MP4, 480p, H.264"),
	VIDEO_360 (134, true, false, "", "MP4, 360p, H.264"),
	VIDEO_240 (133, true, false, "", "MP4, 240p, H.264"),
	VIDEO_144 (160, true, false, "", "MP4, 144p, H.264"),

	AUDIO_256 (141, false, true, "", "MP4 AAC 256"),
	AUDIO_128 (140, false, true, "", "MP4 AAC 128"),
	AUDIO_48 (139, false, true, "", "MP4 AAC 48"),
	
	MP4_3072 (38, true, true, "3072.png", "MP4 {width: 4096, height: 3072, acodec: AAC, vcodec: H.264}"),
	MP4_1080 (37, true, true, "1080.png", "MP4 {width: 1920, height: 1080, acodec: AAC, vcodec: H.264}"),
	MP4_720 (22, true, true, "720.png", "MP4 {width: 1280, height: 720, acodec: AAC, vcodec: H.264}"),
	FLV_480 (35, true, true, "480.png", "FLV {width: 854, height: 480, acodec: AAC, vcodec: H.264}"),
	MP4_360 (18, true, true, "360.png", "MP4 {width: 480, height: 360, acodec: AAC, vcodec: H.264}"),
	FLV_360 (34, true, true, "360.png", "FLV {width: 640, height: 360, acodec: AAC, vcodec: H.264}"),
	FLV_240 (5, true, true, "240.png", "FLV {width: 400, height: 240, acodec: MP3, vcodec: SVQ}"),
	MOBILE_2 (36, true, true, "3gp2.png", "3GP {240p MPEG-4 Visual Simple 0.17 AAC 38}"),
	MOBILE_1 (17, true, true, "3gp1.png", "3GP {144p MPEG-4 Visual Simple 0.05 AAC 24}");
	
	private final int itag;
	private final ImageIcon image;
	private final String description;
	private final boolean video;
	private final boolean audio;
	
	private Format(int itag, boolean video, boolean audio, String image, String description){
		this.itag = itag;
		this.image = new ImageIcon(Format.class.getResource("/images/" + image));
		this.description = description;
		this.video = video;
		this.audio = audio;
	}
	
	public int getItag(){
		return itag;
	}
	
	public ImageIcon getImage(){
		return image;
	}
	
	public String getDescription(){
		return description;
	}
	
	public boolean isVideo(){
		return video;
	}
	
	public boolean isAudio(){
		return audio;
	}
	
	public static boolean isSameType(Format input, Format format){
		return input.isVideo() == format.isVideo() && input.isAudio() == format.isAudio();
	}
}
